package com.ninetaildemonfox.zdl.socialproject.mvp.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.ninetaildemonfox.zdl.socialproject.R;
import com.ninetaildemonfox.zdl.socialproject.mvp.ui.adapter.viewholder.DynameicAdViewHolder;

import java.util.Map;

/**
 * 创建人： Nine tails fox
 * 创建时间： 2019/7/19
 * 功能描述：
 * 联系方式：1037438704@qq.com
 *
 * @author NineTailDemonFox
 */

public class DynameicAdapter extends RecyclerArrayAdapter<Map<String, String>> {
    private LayoutInflater layoutInflater;
    private int count;

    public DynameicAdapter(Context context, int count) {
        super(context);
        layoutInflater = LayoutInflater.from(context);
        this.count = count;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        DynameicAdViewHolder dynameicAdViewHolder = new DynameicAdViewHolder(layoutInflater.inflate(R.layout.list_dyname, parent, false), count);
        dynameicAdViewHolder.setmOnClick(new DynameicAdViewHolder.ItemOnClick() {
            @Override
            public void onClick(int position, Map<String, String> data, int type) {
                if (itemOnClick != null) {
                    itemOnClick.onClick(position, data, type);
                }
            }
        });

        return dynameicAdViewHolder;
    }


    public interface ItemOnClick {
        void onClick(int position, Map<String, String> data, int type);
    }

    private ItemOnClick itemOnClick;

    public void setmOnClick(ItemOnClick mOnClick) {
        this.itemOnClick = mOnClick;
    }
}
